import { ref, computed } from 'vue';
import { defineStore } from 'pinia';
import { get_moreData } from '@/utils/api';
export const useCounterStore = defineStore('counter', {
  // 开启数据持久化
  state: () => ({
    ImgdataList: [],
  }),
  getters: {},
  actions: {
    increment() {
      // 调用get_moreData函数获取数据
      get_moreData()
        .then((ImgList) => {
          if (ImgList.data.code === 200) {
            this.ImgdataList = ImgList.data.data;
          }
        })
        .catch((error) => {
          console.log(error);
        });
    }
  }
});
export const useInfo = defineStore('users', {
  // 开启数据持久化
  persist:true,
  state: () => ({
    user: {}
  }),
  getters: {},
  actions: {
    getuser() {
      this.user = JSON.parse(localStorage.getItem('userinfo') || '{}' as string);
    }
  }
});
